function [ctl] = dupe(C);
% dupe removes duplicates from the current userdata control list.
% a dupe is defined as an entry which is the same with respect to:
% filename, records, protocol, subtraction setting and subtraction file.
% P. Manis 27 Mar 1999.
%
ctl=[];
if(isempty(C))
   QueMessage('Empty control list');
   return;
end

NSF = size(C); % make sure have current size
mark = []; % set up the marking array for deletion...
k=1;
for i=1:NSF(2) 
   markit=0;
   a = find([C(i).seqname] == [C.seqname]); % same sequence name
   if(length(a)>1)
      u = a(2);
      %      disp(sprintf('Compare i: %d u: %d ',i, u))
      if(u > i)
         if(strcmp(C(i).protocol, C(u).protocol)) % have same protocol
            if((C(i).recbeg == C(u).recbeg) & (C(i).recend == C(u).recend))
               if(strcmp(C(i).subtract, C(u).subtract)) % both are subtraction
                  if(strcmp(C(i).linkfile, C(u).linkfile))
                     markit=1;
                     disp(sprintf('Marking for Deletion: u: %d  s: %15.4f  f: %s',...
                        u, C(u).seqname, C(u).filename))
                  end
               end
            end
         end
      end
   end
   if(markit==0)
      mark(k)=i;
      k = k+1;
   end
end

ctl = C([mark]);

